Imports System.Data.SqlClient

Public Class HangMuc
    Private sMaHangMuc As String
    Private sTenHangMuc As String

    Public Property MaHangMuc() As String
        Get
            Return sMaHangMuc
        End Get
        Set(ByVal Value As String)
            sMaHangMuc = Value
        End Set
    End Property

    Public Property TenHangMuc() As String
        Get
            Return sTenHangMuc
        End Get
        Set(ByVal Value As String)
            sTenHangMuc = Value
        End Set
    End Property

End Class


Public Class HangMucF

    Public Function GetAll() As DataTable
        Dim myProjCnn As New ProjectConnection
        Dim myCnn As New SqlConnection
        Dim myDat As New SqlDataAdapter
        Dim myDtb As New DataTable

        myCnn = myProjCnn.GetConnection
        myCnn.Open()

        Dim myCmd As New SqlCommand
        With myCmd
            .Connection = myCnn
            .CommandType = CommandType.StoredProcedure
            .CommandText = "HangMuc_GetAll"

        End With

        myDat = New SqlDataAdapter(myCmd)
        myDat.Fill(myDtb)
        Return myDtb
        myCnn.Close()
        myCnn.Dispose()
    End Function

    Public Function GetWhereMaHangMuc(ByVal MaHangMuc As String) As DataTable
        Dim myProjCnn As New ProjectConnection
        Dim myCnn As New SqlConnection
        Dim myDat As New SqlDataAdapter
        Dim myDtb As New DataTable

        myCnn = myProjCnn.GetConnection
        myCnn.Open()

        Dim myCmd As New SqlCommand
        With myCmd
            .Connection = myCnn
            .CommandType = CommandType.StoredProcedure
            .CommandText = "HangMuc_GetWhereMaHangMuc"

            .Parameters.Add(New SqlClient.SqlParameter("@mahangmuc", SqlDbType.Char))
            .Parameters("@mahangmuc").Value = MaHangMuc

        End With

        myDat = New SqlDataAdapter(myCmd)
        myDat.Fill(myDtb)
        Return myDtb
        myCnn.Close()
    End Function


End Class


